﻿using System;
using System.Collections.Generic;

namespace Topro.Entity
{
    /// <summary>
    /// 
    /// </summary>
    public interface IPagedList
    {
        int CurrentPageIndex { get; set; }
        int PageSize { get; set; }
        int TotalCount { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class PagedList<T> : PagedList
    {
        /// <summary>
        /// 当前页数据
        /// </summary>
        public IEnumerable<T> TData { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class Table<T>
    {
        /// <summary>
        /// 状态码
        /// </summary>
        public int Code { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        public string Msg { get; set; }

        /// <summary>
        /// 总数
        /// </summary>
        public int Count { get; set; }

        /// <summary>
        /// 数据
        /// </summary>
        public IEnumerable<T> Data { get; set; }
    }

    /// <summary>
    /// 分页模型
    /// </summary>>
    public class PagedList : IPagedList
    {
        /// <summary>
        /// 状态
        /// </summary>
        public bool Success { get; set; }

        /// <summary>
        /// 状态代码
        /// </summary>
        public string StatusCode { get; set; }

        /// <summary>
        /// 错误编码
        /// </summary>
        public string ErrorCode { get; set; }

        /// <summary>
        /// 错误消息
        /// </summary>
        public string ErrorMessage { get; set; }

        /// <summary>
        /// 当前页码
        /// </summary>
        private int pageSize = 10;

        /// <summary>
        /// 当前索引
        /// </summary>
        public int CurrentPageIndex { get; set; }

        /// <summary>
        /// 每页显示数
        /// </summary>
        public int PageSize
        {
            get { return pageSize; }
            set { pageSize = value; }
        }

        /// <summary>
        /// 数据总数
        /// </summary>
        public int TotalCount { get; set; }
        /// <summary>
        /// 分页数
        /// </summary>
        public int TotalPageCount { get { return (int)Math.Ceiling(TotalCount / (double)PageSize); } }

    }

    public class DataGrid<T>
    {
        /// <summary>
        /// 状态
        /// </summary>
        public bool Success { get; set; }

        /// <summary>
        /// 状态代码
        /// </summary>
        public string StatusCode { get; set; }

        /// <summary>
        /// 错误编码
        /// </summary>
        public string ErrorCode { get; set; }

        /// <summary>
        /// 错误消息
        /// </summary>
        public string ErrorMessage { get; set; }

        /// <summary>
        /// 总记录数
        /// </summary>
        public int Total { get; set; }

        /// <summary>
        /// 当前页数据
        /// </summary>
        public IEnumerable<T> Rows { get; set; }

        /// <summary>
        /// Footer
        /// </summary>
        public List<T> Footer { get; set; }
        
    }

    public class Footer
    {
        /// <summary>
        /// 总各
        /// </summary>
        public string Balance { get; set; }
    }
}
